package com.androider.timememory.activity;

import com.androider.timememory.R;
import com.androider.timememory.utils.ImageUtil;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

public class Video extends Activity {
	private TextView date;
	private TextView category;
	private TextView note;
	private ImageView image;
	private Bitmap bmp;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.show_video);
		
		date = (TextView) findViewById(R.id.date);
		category = (TextView) findViewById(R.id.category);
		note = (TextView) findViewById(R.id.note);
		image = (ImageView) findViewById(R.id.image);
		
		Bundle b = getIntent().getExtras();
		date.append(b.getString("date"));
		category.append(b.getString("category"));
		note.append(b.getString("note"));
		final String path = b.getString("content");
		bmp = ImageUtil.getVideoThumbnail(path);
		image.setImageBitmap(bmp);
		
		image.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(Video.this, AlbumPlayVideo.class);
				intent.putExtra(AlbumPlayVideo.VIDEO_PATH, path);
				startActivity(intent);
			}
			
		});
	}

	@Override
	protected void onDestroy() {
	    if(image != null) {
            image.setImageBitmap(null);
            image = null;
        }
        
        if(bmp != null) {
            bmp.recycle();
        }
        super.onDestroy();
	}
	
}
